package com.tbit.uqbike.object.pojo.vo;

import com.tbit.uqbike.object.pojo.RideLogDetails;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Objects;

/**
 * @Author:BUGTian
 * @DATE: 2022/11/17
 */
@Data
public class RideLogDetailsVO extends RideLogDetails {
    /**
     * 已退款金额
     */
    private Double isRefundMoney;
    /**
     * 骑行费用已退款金额
     */
    private Double refundRideMoney;
    /**
     * 骑行费用剩余可退
     */
    private Double returnableRideMoney;
    /**
     * 罚款费用已退款金额
     */
    private Double refundFineMoney;
    /**
     * 罚款费用剩余可退
     */
    private Double returnableFineMoney;

    /**
     * 礼品卡已退款金额
     */
    private Double refundGiftCardMoney;

    /**
     * 礼品卡剩余可退
     */
    private Double returnableGiftCardMoney;

    /**
     * 最近一笔退款记录备注
     */
    private String refundRemark;

    /**
     * 退款状态
     */
    private Integer refundStatus;

    /**
     * 订单费用申诉图片地址
     */
    private String url;
    /**
     * 订单费用申诉问题类型
     */
    private String type;
    /**
     * 订单费用申诉描述
     */
    private String remark;
    /**
     * 订单费用申诉统计相关信息
     */
    private FeeAppealInfoVO feeAppealInfoVO;

    /**当前订单用户的总骑行订单数*/
    private Integer userOrderNum;

    /**当前订单用户的总退款次数*/
    private Integer returnMoneyNum;
    /**当前用户的总费用申述数*/
    private Integer  userFeeAppealNum;

    public void setUserOrderNum(Integer userOrderNum) {
        this.userOrderNum = Objects.isNull(userOrderNum) ? 0 : userOrderNum;
    }

    public void setReturnMoneyNum(Integer returnMoneyNum) {
        this.returnMoneyNum = Objects.isNull(returnMoneyNum) ? 0 : returnMoneyNum;
    }

    public void setUserFeeAppealNum(Integer userFeeAppealNum) {
        this.userFeeAppealNum = Objects.isNull(userFeeAppealNum) ? 0 : userFeeAppealNum;
    }

    /**
     * 计算剩余可退
     */
    public void computeReturnable() {
        returnableRideMoney = new BigDecimal(Double.valueOf(getDeductionCyclingMoney()).toString()).subtract(new BigDecimal(refundRideMoney.toString())).doubleValue();
        returnableFineMoney = new BigDecimal(Double.valueOf(getDeductionFineMoney()).toString()).subtract(new BigDecimal(refundFineMoney.toString())).doubleValue();
        returnableGiftCardMoney = new BigDecimal(Double.valueOf(getGiftCardDeductionMoney()).toString()).subtract(new BigDecimal(refundGiftCardMoney.toString())).doubleValue();
    }

}
